--- categories: Algorithm techniques, Data structures --- Not to be confused with [convex hull](Convex hull), the **convex hull trick** is a [dynamic programming optimization](Dynamic programming optimization) technique. It can be thought of as a [data structure](Data structure) supporting the following operations: - Insert(ax+b): insert the line $ax+b$ into the data structure - GetMin(x): considering all the lines that have been inserted so far, return the one that has the minimum value at $x$ ## Applicability The convex hull trick applies when the dynamic programming recurrence is approximately of the form $$ \mathrm{dp}[i] = \min_{j TODO: Talk about dynamic vs. static variants Sometimes the above form appears within a more complex recurrence, as is the case for $$ \mathrm{dp}[k][i] = \min_{j [^2]: [^3]: